# -*- coding: utf-8 -*-
# @Time : 2021/2/2 9:12
# @Author : geyue
# @Site : 
# @File : signals.py
# @Software: PyCharm

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from notifications.signals import notify


@receiver(post_save, sender=User)
def send_notification(sender, instance, **kwargs):
    # 当用户第一次注册时，发送一条注册信息
    if kwargs['created'] == True:
        verb = '欢迎注册!'
        description = "系统正在完善中，希望大家多提宝贵意见！"
        notify.send(sender=instance, recipient=instance, verb=verb, description=description, action_object=instance)